using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using yWriter6.My.Resources;

namespace yWriter6
{
	[DesignerGenerated]
	internal class frmPickFont : Form
	{
		private IContainer components;

		public ToolTip ToolTip1;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdOK")]
		private Button _cmdOK;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdCancel")]
		private Button _cmdCancel;

		[CompilerGenerated]
		[AccessedThroughProperty("cmbFontSize")]
		private ComboBox _cmbFontSize;

		[CompilerGenerated]
		[AccessedThroughProperty("cmbFont")]
		private ComboBox _cmbFont;

		[CompilerGenerated]
		[AccessedThroughProperty("Label1")]
		private Label _Label1;

		public bool Saved;

		private string mvarFontNameSettingTitle;

		private string mvarFontSizeSettingTitle;

		public virtual Button cmdOK
		{
			[CompilerGenerated]
			get
			{
				return _cmdOK;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdOK_Click;
				Button cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click -= value2;
				}
				_cmdOK = value;
				cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click += value2;
				}
			}
		}

		public virtual Button cmdCancel
		{
			[CompilerGenerated]
			get
			{
				return _cmdCancel;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdCancel_Click;
				Button cmdCancel = _cmdCancel;
				if (cmdCancel != null)
				{
					cmdCancel.Click -= value2;
				}
				_cmdCancel = value;
				cmdCancel = _cmdCancel;
				if (cmdCancel != null)
				{
					cmdCancel.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("cmbFontSize")]
		public virtual ComboBox cmbFontSize
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("cmbFont")]
		public virtual ComboBox cmbFont
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("Label1")]
		public virtual Label Label1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[DebuggerNonUserCode]
		protected override void Dispose(bool Disposing)
		{
			if (Disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(Disposing);
		}

		[System.Diagnostics.DebuggerStepThrough]
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			ToolTip1 = new System.Windows.Forms.ToolTip(components);
			cmdOK = new System.Windows.Forms.Button();
			cmdCancel = new System.Windows.Forms.Button();
			cmbFontSize = new System.Windows.Forms.ComboBox();
			cmbFont = new System.Windows.Forms.ComboBox();
			Label1 = new System.Windows.Forms.Label();
			SuspendLayout();
			cmdOK.BackColor = System.Drawing.SystemColors.Control;
			cmdOK.Cursor = System.Windows.Forms.Cursors.Default;
			cmdOK.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdOK.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdOK.Location = new System.Drawing.Point(317, 101);
			cmdOK.Name = "cmdOK";
			cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdOK.Size = new System.Drawing.Size(73, 35);
			cmdOK.TabIndex = 4;
			cmdOK.Text = "OK";
			cmdOK.UseVisualStyleBackColor = true;
			cmdCancel.BackColor = System.Drawing.SystemColors.Control;
			cmdCancel.Cursor = System.Windows.Forms.Cursors.Default;
			cmdCancel.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdCancel.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdCancel.Location = new System.Drawing.Point(16, 101);
			cmdCancel.Name = "cmdCancel";
			cmdCancel.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdCancel.Size = new System.Drawing.Size(73, 35);
			cmdCancel.TabIndex = 3;
			cmdCancel.Text = "Cancel";
			cmdCancel.UseVisualStyleBackColor = true;
			cmbFontSize.BackColor = System.Drawing.SystemColors.Window;
			cmbFontSize.Cursor = System.Windows.Forms.Cursors.Default;
			cmbFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			cmbFontSize.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmbFontSize.ForeColor = System.Drawing.SystemColors.WindowText;
			cmbFontSize.Location = new System.Drawing.Point(265, 21);
			cmbFontSize.Name = "cmbFontSize";
			cmbFontSize.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmbFontSize.Size = new System.Drawing.Size(69, 25);
			cmbFontSize.TabIndex = 1;
			cmbFont.BackColor = System.Drawing.SystemColors.Window;
			cmbFont.Cursor = System.Windows.Forms.Cursors.Default;
			cmbFont.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmbFont.ForeColor = System.Drawing.SystemColors.WindowText;
			cmbFont.Location = new System.Drawing.Point(72, 21);
			cmbFont.Name = "cmbFont";
			cmbFont.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmbFont.Size = new System.Drawing.Size(187, 25);
			cmbFont.Sorted = true;
			cmbFont.TabIndex = 0;
			cmbFont.Text = "cmbFont";
			Label1.BackColor = System.Drawing.SystemColors.Control;
			Label1.Cursor = System.Windows.Forms.Cursors.Default;
			Label1.Font = new System.Drawing.Font("Segoe UI", 10f);
			Label1.ForeColor = System.Drawing.SystemColors.ControlText;
			Label1.Location = new System.Drawing.Point(12, 24);
			Label1.Name = "Label1";
			Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
			Label1.Size = new System.Drawing.Size(54, 21);
			Label1.TabIndex = 2;
			Label1.Text = "Font:";
			Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 14f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			BackColor = System.Drawing.SystemColors.Control;
			base.ClientSize = new System.Drawing.Size(402, 148);
			base.Controls.Add(cmdOK);
			base.Controls.Add(cmdCancel);
			base.Controls.Add(cmbFontSize);
			base.Controls.Add(cmbFont);
			base.Controls.Add(Label1);
			Cursor = System.Windows.Forms.Cursors.Default;
			Font = new System.Drawing.Font("Arial", 8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
			base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			base.Location = new System.Drawing.Point(4, 23);
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "frmPickFont";
			RightToLeft = System.Windows.Forms.RightToLeft.No;
			base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			Text = "Choose Editor Font";
			ResumeLayout(false);
		}

		public frmPickFont(string FontNameSettingTitle, string FontSizeSettingTitle)
		{
			base.Load += frmPickFont_Load;
			mvarFontNameSettingTitle = "";
			mvarFontSizeSettingTitle = "";
			InitializeComponent();
			mvarFontNameSettingTitle = FontNameSettingTitle;
			mvarFontSizeSettingTitle = FontSizeSettingTitle;
		}

		private void cmdCancel_Click(object eventSender, EventArgs eventArgs)
		{
			Hide();
			cDelay.DoEvents();
		}

		private void cmdOK_Click(object eventSender, EventArgs eventArgs)
		{
			Saved = true;
			Hide();
			cDelay.DoEvents();
			SaveCurrentFont();
		}

		private void frmPickFont_Load(object eventSender, EventArgs eventArgs)
		{
			try
			{
				base.Icon = Resources.yWriter5_Ico;
				if (Operators.CompareString(clsShared.cLang.CurrentLanguage, "English", TextCompare: false) != 0)
				{
					clsShared.cLang.TranslateForm(this);
				}
			}
			catch (Exception ex)
			{
				ProjectData.SetProjectError(ex);
				Exception ex2 = ex;
				clsShared.cLog.AddAction(ex2, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
			try
			{
				clsShared.cFormFont.SetFormFont(this, clsShared.cSettings.sGet("FormFont", modVariables.DefaultUIFont.Name), clsShared.cSettings.sGet("UIFontSize", modVariables.DefaultUIFont.Size));
			}
			catch (Exception ex3)
			{
				ProjectData.SetProjectError(ex3);
				Exception ex4 = ex3;
				clsShared.cLog.AddAction(ex4, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
			try
			{
				cmbFontSize.Items.Clear();
				int num = 8;
				do
				{
					cmbFontSize.Items.Add(num);
					num += 2;
				}
				while (num <= 48);
			}
			catch (Exception ex5)
			{
				ProjectData.SetProjectError(ex5);
				Exception ex6 = ex5;
				clsShared.cLog.AddAction(ex6, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
			try
			{
				cmbFont.Items.Clear();
				FontFamily[] families = FontFamily.Families;
				foreach (FontFamily fontFamily in families)
				{
					cmbFont.Items.Add(fontFamily.Name);
				}
			}
			catch (Exception ex7)
			{
				ProjectData.SetProjectError(ex7);
				Exception ex8 = ex7;
				clsShared.cLog.AddAction(ex8, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
			try
			{
				cmbFontSize.Text = clsShared.cSettings.sGet(mvarFontSizeSettingTitle, "12");
				cmbFont.Text = clsShared.cSettings.sGet(mvarFontNameSettingTitle, "Segoe UI");
			}
			catch (Exception ex9)
			{
				ProjectData.SetProjectError(ex9);
				Exception ex10 = ex9;
				clsShared.cLog.AddAction(ex10, MethodBase.GetCurrentMethod());
				ProjectData.ClearProjectError();
			}
		}

		private void SaveCurrentFont()
		{
			clsShared.cSettings.sSet(mvarFontSizeSettingTitle, cmbFontSize.Text);
			clsShared.cSettings.sSet(mvarFontNameSettingTitle, cmbFont.Text);
		}
	}
}
